package com.qf.web.servlet;

import com.qf.pojo.User;
import com.qf.service.AdminUserService;
import com.qf.service.impl.AdminUserServiceImpl;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 千锋教育
 * @Company http://www.mobiletrain.org/
 * @Version 1.0
 */

@WebServlet("/adminuserservlet")
public class AdminUserServlet  extends BaseServlet{

    AdminUserService adminUserService = new AdminUserServiceImpl();

    public String adminLogin(HttpServletRequest request, HttpServletResponse response){
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        User user = adminUserService.login(username, password);
        if(user != null){
            request.getSession().setAttribute("admin", user);
            return "redirect:/admin/admin.jsp";
        }
        return "redirect:/admin/login.jsp";

    }
}
